<%@page import="com.framework.entity.Global"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="com.biz.utils.ConfigUtil" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
    String resoursUrl = ConfigUtil.get("RESOURCES_URL");
    String picUrl=ConfigUtil.get("OSSURL");
%>

<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="UTF-8">
<title>完善个人资料</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<jsp:include page="/jsp/inc.jsp"></jsp:include>

</head>
<body style="background-color: #fff;">
<div class="">
 <form id="form" name="form">
	<div class="filllable">
		<input type="hidden" id="meb_id" value="${id}">
		<input type="hidden" id="page_type" value="${page_type}" name="pbaseUser.page_type">
		<label for="" class="">姓名：</label>
		<div class="fillinput">
			<input type="text" class="zlinput" placeholder="请输入真实姓名" name="pbaseUser.userName" id="userName" value="${pbaseUser.userName}">
		</div>
		<br class="clear"/>
	</div>
	<div class="filllable">
		<label for="" class="">手机：</label>
		<div class="fillinput">
			<input type="text"  class="zlinput" placeholder="请输入手机号" autocomplete="off" name="pbaseUser.phone" id="phone"  value="${pbaseUser.phone}">
		</div>
		<br class="clear"/>
	</div>
	<%--<div class="filllable">--%>
		<%--<label for="" class="">验证码：</label>--%>
		<%--<div class="fillinput">--%>
			<%--<input type="text" class="zlinput" placeholder="请输入验证码" name="pbaseUser.authCode" id="authCode">--%>
		<%--</div>--%>
		<%--<span class="getyzm" onclick="getCode()" id="Time">获取</span>--%>
		<%--<br class="clear"/>--%>
	<%--</div>--%>
 </form>
</div>

<div class="loginform">
	<div class="">
		<button type="button" class="longbtn btn-blue" id="poptip" onclick="updatInfo()">下一步</button>
	</div>
</div>

<script src="<%=basePath%>resources/js/ydui.js"></script>
<script type="text/javascript">
    var ajaxpath="${pageContext.request.contextPath}";
    var sendMobile, sendCode;//保存发送的手机号和验证码
    var phtest = /^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9])\d{8}$/;//手机格式验证
    var Ltime=true;
    //获取短信验证码
		function TimeClock() {
            var time=60;
            if (Ltime) {
                Ltime=false;
                $("#Time").addClass("getyzm_after");
                var t=setInterval(function () {
                    time--;
                    $("#Time").html(time+"s");
                    if (time == 0) {
                        clearInterval(t);
                        $("#Time").html("获取");
                        Ltime=true;
                        $("#Time").removeClass("getyzm_after");
                    }
                },1000)
            }
        }
		//获取验证码
	function getCode() {
		    if(Ltime){
		var phone=$("#phone").val();
        if (!phtest.test(phone)) {
            window.YDUI.dialog.alert('手机号格式错误！');
            return;
        }
        var url_PhoneRegisted = ajaxpath+"/userCenter/queryRegInfoByPhone.ac?phone="+ phone+"&guid="+ new Date();
        $.get(url_PhoneRegisted, function(data){
            data = eval("(" + data + ")");
            if(data.result=="nouser"){
                TimeClock();
                sendMsg(phone);
            }else{
                window.YDUI.dialog.alert('该号码已被注册！');
            }
        });
            }
    }

    //发送验证码
    function sendMsg(phone) {
        var url_send = ajaxpath+"/sys/sendMsg.ac?mobile=" + phone + "&guid="+ new Date();
        $.get(url_send, function(data) {
            data = eval("(" + data + ")");
            sendMobile = data.phone;
            sendCode = data.code;
            window.YDUI.dialog.alert('验证码已发送,请注意查收！');
        });
    }
    //更新信息
	function updatInfo(){
		    var userName=$("#userName").val();
		    var phone=$("#phone").val();
//		    var authCode=$("#authCode").val();

		    if(userName==null||userName==""){
                window.YDUI.dialog.alert('请填写姓名！');
				return;
		    }
			if (!phtest.test(phone)) {
				window.YDUI.dialog.alert('手机号格式错误！');
				return;
			}
//			if(authCode==null||authCode==""){
//				window.YDUI.dialog.alert('请填写验证码！');
//				return;
//			}
//        if(sendMobile!=phone||sendCode!=authCode){
//            window.YDUI.dialog.alert('手机号或验证码错误');
//            return;
//        }

        var url_submit = ajaxpath+"/userCenter/updateRegister.ac?phone=" + phone+"&userName="+userName+"&guid="+ new Date();
        $.get(url_submit, function(data) {
            data = eval("(" + data + ")");
            if (data.result == "success") {
                toUrl();
            } else {
                window.YDUI.dialog.alert(data.msg);
            }
        });
	}
	
	function toUrl() {
		var page_type=$("#page_type").val();
		var id=$("#meb_id").val();
		if(page_type=="0"){
            window.location.href='${pageContext.request.contextPath}/mebactivity/toMebactivityDetail.ac?id='+id;
		}else if(page_type=="1"){
            window.location.href='${pageContext.request.contextPath}/userCenter/toUserInfo.ac';
		}
    }

</script>


</body>
</html>
